'use strict';
app.controller('promotionPosterCtrl', ['$scope', 'toaster', 'utilService', 'FileUploader', '$cookies', '$state', '$timeout', '$modal', function ($scope, toaster, utilService, FileUploader, $cookies, $state, $timeout, $modal) {
    $scope.promotionPosterListVO = {
        typeObject: [
            {name: '商品', value: '0'},
            {name: '店铺', value: '1'},
            {name: '平台', value: '2'}
        ]
    };
    $scope.query = function () {
        $scope.list={};
        utilService.queryForPagingList($scope, {
            url: $scope.app.domain + 'promotion/poster',
            params: $scope.promotionPosterListVO
        }).then(function (rlt) {
        });
    }
    $scope.query();
    //下载海报
    $scope.download = function (item) {
        item.sessionId=$cookies.sessionId;
        item.isDownload=1;
        openModal("确定下载推广海报吗?");
        function openModal(msg) {
            utilService.modal($modal, $scope, {
                title: "温馨提示",
                controller: "downloadPromotionPosterCtrl",
                message: msg,
                data: item
            });
        }
    }
}])
app.controller('downloadPromotionPosterCtrl', ['$scope', '$modalInstance', 'modalData', 'promotionPosterService', function ($scope, $modalInstance, modalData, promotionPosterService) {
    $scope.modal = modalData;
    $scope.param = modalData.data;
    $scope.AllowToDelete = true;
    $scope.ok = function () {
        if (!$scope.AllowToDelete) {
            return;
        }
        $scope.AllowToDelete = false;
        promotionPosterService.download($scope);
        $modalInstance.dismiss('success');
    }
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    }
}]);